class Person < ActiveRecord::Base

  has_and_belongs_to_many :events
  belongs_to :user
  has_one :visitor

  validates_presence_of :name

  def roles
    roles = []
    roles.push("volunteer") if self.is_volunteer?
    roles.push("keyholder") if self.is_keyholder?
    roles.push("boardmember") if self.is_boardmember?

    return roles
  end

  def volunteer(event)
    self.events.push(event)
  end

  def is_a_volunteer_for(event)
    event.people.each do |person|
      if self == person
        return true
      end
    end
    return false
  end

end
